package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoPrintingPicture;
import com.muyu.danmo.service.IDanmoPrintingPictureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 印刷出版图片Controller
 *
 * @author yangle
 * @date 2024-10-15
 */
@RestController
@RequestMapping("/printingPicture")
public class DanmoPrintingPictureController extends BaseController
{
    @Autowired
    private IDanmoPrintingPictureService danmoPrintingPictureService;

    /**
     * 查询印刷出版图片列表
     */
//    @RequiresPermissions("system:printingPicture:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoPrintingPicture>> list(DanmoPrintingPicture danmoPrintingPicture)
    {
        startPage();
        List<DanmoPrintingPicture> list = danmoPrintingPictureService.selectDanmoPrintingPictureList(danmoPrintingPicture);
        return getDataTable(list);
    }

    /**
     * 导出印刷出版图片列表
     */
//    @RequiresPermissions("system:printingPicture:export")
    @Log(title = "印刷出版图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoPrintingPicture danmoPrintingPicture)
    {
        List<DanmoPrintingPicture> list = danmoPrintingPictureService.selectDanmoPrintingPictureList(danmoPrintingPicture);
        ExcelUtil<DanmoPrintingPicture> util = new ExcelUtil<DanmoPrintingPicture>(DanmoPrintingPicture.class);
        util.exportExcel(response, list, "印刷出版图片数据");
    }

    /**
     * 获取印刷出版图片详细信息
     */
//    @RequiresPermissions("system:printingPicture:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoPrintingPictureService.selectDanmoPrintingPictureById(id));
    }

    /**
     * 新增印刷出版图片
     */
//    @RequiresPermissions("system:printingPicture:add")
    @Log(title = "印刷出版图片", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoPrintingPicture danmoPrintingPicture)
    {
        return toAjax(danmoPrintingPictureService.insertDanmoPrintingPicture(danmoPrintingPicture));
    }

    /**
     * 修改印刷出版图片
     */
//    @RequiresPermissions("system:printingPicture:edit")
    @Log(title = "印刷出版图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoPrintingPicture danmoPrintingPicture)
    {
        return toAjax(danmoPrintingPictureService.updateDanmoPrintingPicture(danmoPrintingPicture));
    }

    /**
     * 删除印刷出版图片
     */
//    @RequiresPermissions("system:printingPicture:remove")
    @Log(title = "印刷出版图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoPrintingPictureService.deleteDanmoPrintingPictureByIds(ids));
    }
}
